package com.yml.ktbus.logger

import android.util.Log
import java.util.logging.Level

/**
 * Created by liaohailiang on 2019-09-10.
 */
class DefaultLogger : Logger {
    override fun log(level: Level?, msg: String?) {
        when (level) {
            Level.SEVERE -> Log.e(TAG, msg)
            Level.WARNING -> Log.w(TAG, msg)
            Level.INFO -> Log.i(TAG, msg)
            Level.CONFIG -> Log.d(TAG, msg)
            Level.OFF -> Log.v(TAG, msg)
        }
    }

    override fun log(level: Level?, msg: String?, th: Throwable?) {
        when (level) {
            Level.SEVERE -> Log.e(TAG, msg, th)
            Level.WARNING -> Log.w(TAG, msg, th)
            Level.INFO -> Log.i(TAG, msg, th)
            Level.CONFIG -> Log.d(TAG, msg, th)
            Level.OFF -> Log.v(TAG, msg, th)
        }
    }

    companion object {
        private const val TAG = "[KotlinLiveEventBus]"
    }
}